#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <limits.h>

#define DEBUG	1

#define CAP	40
#define MASK	(CHAR_BIT * sizeof (int) - 1)

#define MIN(a, b)	((a) > (b) ? (b) : (a))
#define MAX(a, b)	((a) < (b) ? (b) : (a))

/*
 * a proper solution
 */

int
main(int argc, char **argv)
{
	int in;
	static int a[CAP], ans1, ans2;
	register int i = 0, parity = 0;

	while (scanf("%d", &in) == 1) {
		for (i = 0; i <= MASK; i++)
			if ((in >> i) & 1)
				a[i] ^= in;
		parity ^= in;
	}

	#ifdef DEBUG
	for (i = 0; i <= MASK; i++)
		if (a[i]) {
			fprintf(stderr, "%5d: %d\n", i, a[i]);
			if (ans1 == 0)
				ans1 = a[i];
			else if (ans2 == 0)
				ans2 = a[i];
		}
	#endif

	for (i = 0; i <= MASK; ++i)
		if ((parity >> i) & 1) {
			fprintf(stderr, "\ta[i]=%d (parity^a[i])=%d\n", ans1 = a[i], ans2 = parity ^ a[i]);
			break;
		}

	printf("%d %d\n", MIN(ans1, ans2), MAX(ans1, ans2));

	return 0;
}
